import request from '@/utils/request'

/**
 * 运动项目管理API接口
 */

// 分页查询项目列表
export function getProjectPage(currentPage, pageSize, queryParams) {
  return request({
    url: `/api/projects/page/${currentPage}/${pageSize}`,
    method: 'get',
    params: queryParams
  })
}

// 根据ID查询项目详情
export function getProjectById(projectId) {
  return request({
    url: `/api/projects/${projectId}`,
    method: 'get'
  })
}

// 新增项目
export function addProject(projectData) {
  return request({
    url: '/api/projects',
    method: 'post',
    data: projectData
  })
}

// 更新项目信息
export function updateProject(projectData) {
  return request({
    url: '/api/projects',
    method: 'put',
    data: projectData
  })
}

// 删除项目
export function deleteProject(projectId) {
  return request({
    url: `/api/projects/${projectId}`,
    method: 'delete'
  })
}

// 批量删除项目
export function batchDeleteProjects(projectIds) {
  return request({
    url: '/api/projects/batch',
    method: 'delete',
    data: projectIds
  })
}

// 更新项目状态
export function updateProjectStatus(projectId, status) {
  return request({
    url: `/api/projects/${projectId}/status`,
    method: 'put',
    params: { status }
  })
}

// 获取项目类型列表
export function getProjectTypes() {
  return request({
    url: '/api/projects/types',
    method: 'get'
  })
}

// 获取项目状态列表
export function getProjectStatuses() {
  return request({
    url: '/api/projects/statuses',
    method: 'get'
  })
}

// 获取性别限制列表
export function getGenderLimits() {
  return request({
    url: '/api/projects/gender-limits',
    method: 'get'
  })
}

// 根据项目类型查询项目列表
export function getProjectsByType(type) {
  return request({
    url: '/api/projects/by-type',
    method: 'get',
    params: { type }
  })
}

// 根据项目状态查询项目列表
export function getProjectsByStatus(status) {
  return request({
    url: '/api/projects/by-status',
    method: 'get',
    params: { status }
  })
}

// 批量更新项目状态
export function batchUpdateProjectStatus(projectIds, status) {
  return request({
    url: '/api/projects/batch-status',
    method: 'put',
    data: { projectIds, status }
  })
}

// 获取热门项目
export function getPopularProjects(limit = 10) {
  return request({
    url: '/api/projects/popular',
    method: 'get',
    params: { limit }
  })
}

// 统计项目总数
export function countProjects() {
  return request({
    url: '/api/projects/count',
    method: 'get'
  })
}

// 根据状态统计项目数量
export function countProjectsByStatus(status) {
  return request({
    url: '/api/projects/count-by-status',
    method: 'get',
    params: { status }
  })
}